import request from '../../utils/request';

// 任务管理相关 API

// 更新任务
export const updateTask = (data: any) => {
    return request({
        url: '/system/api/task/update',
        method: 'put',
        data
    });
};

// 分页查询任务
export const getTaskPage = (params: any) => {
    return request({
        url: '/system/api/task/page',
        method: 'get',
        params
    });
};

// 创建任务
export const createTask = (data: any) => {
    return request({
        url: '/system/api/task/create',
        method: 'post',
        data
    });
};

// 根据任务ID获取任务名称
export const getTaskNameById = (taskId: string) => {
    return request({
        url: `/system/api/task/name/${taskId}`,
        method: 'get'
    });
};

// 获取启用的任务列表
export const getEnabledTaskList = () => {
    return request({
        url: '/system/api/task/list/enabled',
        method: 'get'
    });
};

// 根据任务类型获取任务列表
export const getTaskListByType = (taskType: string) => {
    return request({
        url: `/system/api/task/list/by-type/${taskType}`,
        method: 'get'
    });
};

// 获取任务详情
export const getTaskDetail = (id: string) => {
    return request({
        url: `/system/api/task/detail/${id}`,
        method: 'get'
    });
};

// 批量操作任务
export const batchTask = (data: any) => {
    return request({
        url: '/system/api/task/batch',
        method: 'post',
        data
    });
};

// 删除任务
export const deleteTask = (id: string) => {
    return request({
        url: `/system/api/task/delete/${id}`,
        method: 'delete'
    });
};
